﻿package frEngine.animateControler.visible
{
    import baseEngine.modifiers.*;
    import flash.events.*;
    import frEngine.animateControler.keyframe.*;
    import frEngine.event.*;

    public class VisibleControler extends Modifier
    {

        public function VisibleControler()
        {
            return;
        }// end function

        override public function get type() : int
        {
            return AnimateControlerType.VisibleContoler;
        }// end function

        override protected function calculateFrameValue(param1:int) : void
        {
            var _loc_2:* = getTimeIndex(param1, _keyframes);
            var _loc_3:* = _keyframes[_loc_2];
            _cache[currentFrame] = _loc_3.value;
            return;
        }// end function

        public function getStartVisibleFrame() : int
        {
            var _loc_2:NodeAnimateKey = null;
            var _loc_1:* = _keyframes.length;
            if (_loc_1 == 0)
            {
                return 0;
            }
            var _loc_3:* = _loc_1 - 1;
            while (_loc_3 >= 0)
            {
                
                _loc_2 = _keyframes[_loc_3];
                if (_loc_2.frame <= this._currentFrame && _loc_2.value == 0)
                {
                    if (_loc_3 == (_loc_1 - 1))
                    {
                        return 0;
                    }
                    return _keyframes[(_loc_3 + 1)].frame;
                }
                _loc_3 = _loc_3 - 1;
            }
            return 0;
        }// end function

        override public function parserKeyFrames(param1:Object) : void
        {
            super.parserKeyFrames(param1);
            targetObject3d.visible = _keyframes[0].value;
            FrEventDispatcher.instance.proxyDispatchEvent(this, Event.CHANGE);
            return;
        }// end function

        override public function editKeyFrame(param1:Object, param2:int, param3:String, param4, param5:BezierVo) : Object
        {
            if (param2 == 0)
            {
                targetObject3d.visible = param4;
            }
            var _loc_6:* = super.editKeyFrame(param1, param2, param3, param4, null);
            FrEventDispatcher.instance.proxyDispatchEvent(this, Event.CHANGE);
            return _loc_6;
        }// end function

        override protected function setTargetProperty(param1) : void
        {
            targetObject3d.visible = Boolean(param1);
            return;
        }// end function

    }
}
